package com.bruce.spring.http.client.factory;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;

/**
 * Created by bruce in 2025/6/22 02:17
 */
public class SimpleClientGzipHttpResponse implements ClientHttpResponse {

    private final ClientHttpResponse response;

    public SimpleClientGzipHttpResponse(ClientHttpResponse response) {
        this.response = response;
    }

    @Override
    public HttpStatusCode getStatusCode() throws IOException {
        return response.getStatusCode();
    }

    @Override
    public String getStatusText() throws IOException {
        return response.getStatusText();
    }

    @Override
    public void close() {
        response.close();
    }

    @Override
    public InputStream getBody() throws IOException {
        return new GZIPInputStream(response.getBody());
    }

    @Override
    public HttpHeaders getHeaders() {
        return response.getHeaders();
    }
}
